package com.swgk.core.base.di;

import android.app.Application;

import com.swgk.core.base.model.preference.BasePreferenceSource;
import com.swgk.core.favor.FavorAdapter;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;

/**
 * Description:
 * Author zhengkewen
 * Time 2017/12/11
 */
@Module
public class AppModule {

    private Application application;
    private Class<?> preferenceSourceClass;

    public <T> AppModule(Application application, Class<T> preferenceSourceClass) {
        this.application = application;
        this.preferenceSourceClass = preferenceSourceClass;
    }

    @Provides
    @Singleton
    public Application provideApplication() {
        return application;
    }

    @Provides

    @Singleton
    BasePreferenceSource providePreferenceSource(Application application) {
        return (BasePreferenceSource) new FavorAdapter.Builder(application.getApplicationContext()).build().create(preferenceSourceClass);
    }
}
